package game;

import java.awt.*;

import javax.swing.ImageIcon;
import javax.swing.JLabel;
/*
 * Team: Sting Arrays
 * Creators: Devin La Fleur. and Jonathan Satchell.
 * Game: Defend Chernobly
 */
public class Bullet extends JLabel{
	//class variables
	private ImageIcon img = new ImageIcon("Images/bullet.png");
	private int damage,  b = 0;
	private boolean SHOT;
	private double slope , speedX = 0, speedY = 0;
	//private Location destination;

	public Bullet(int gunDamage){
		//set image size
		setBounds(0,0,20,20);
        //resize image
        img = new ImageIcon(img.getImage().getScaledInstance(getWidth(), getHeight(), Image.SCALE_SMOOTH));
        damage = gunDamage;
        SHOT = false;
	}
	public ImageIcon getImg()
	{
		//img = new ImageIcon(img.getImage().getScaledInstance(getWidth(), getHeight(), Image.SCALE_SMOOTH));
		return img;
	}
	public int getDamage()
	{
		return damage;
	}
	public boolean isShot()
	{
		return SHOT;
	}
	public void shoot(int desX, int desY)
	{
		SHOT = true;
		slope = (double)(this.getY()-desY) / (this.getX() - desX);

		speedX =  Math.cos(slope)*10;
		speedY = -Math.sin(slope) * 10;

		b = (int) ((int)(-1*desY) + (slope*desX));
		//speedY = 5;
		//speedX = (int)(5*slope);
		//speedY = (int)(5*slope);
	}
	public double getXSpeed()
	{
		//speedX= speedX * (75/1000);
		return speedX;
	}
	public double getYSpeed()
	{
		//speedY = (int)((slope)*this.getX() + b);
		//speedY = speedY * (75/1000);
		return speedY;
	}
}
